<?php

class Manage_mag extends CI_Model {

    function getArticles(){
        $articles = $this->mongo_db->get('blog');
        foreach($articles as $key => $value){
            $infos = $this->get_profile_infos->getInfosID($value['user_id']);
            $articles[$key]['user_name'] = $infos['first_name']." ".$infos['last_name'];
            $articles[$key]['user_thumb'] = $infos['profile_pic_thumb'];
        }
        return $articles;
    }
    function addArticle($html,$title,$sdesc,$user_id,$thumb){
        $timestamp = time();
        $data = array(
          'body' => $html,
          'title' => $title,
          'desc' => $sdesc,
          'thumb' => $thumb,
          'user_id' => $user_id,
          'timestamp' => $timestamp
        );
        $insert = $this->mongo_db->insert('blog', $data);

        return $insert;
    }
}

?>